#include "linuxopeninterminalmainwindow.h"
#include "linuxterminalhelper.h"
#include "ui_linuxopeninterminalmainwindow.h"

#include <QStandardPaths>

LinuxOpenInTerminalMainWindow::LinuxOpenInTerminalMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::LinuxOpenInTerminalMainWindow)
{
    ui->setupUi(this);

    auto ok = LinuxTerminalHelper::isTerminalSupported();
    if (ok.first) {
        ui->statusbar->showMessage(QString("当前支持的终端为: %1 - %2").arg(ok.second.command).arg(ok.second.name));
    } else {
        ui->statusbar->showMessage("未发现支持的终端。");
    }
}

LinuxOpenInTerminalMainWindow::~LinuxOpenInTerminalMainWindow()
{
    delete ui;
}

void LinuxOpenInTerminalMainWindow::on_open_config_clicked()
{
    bool ok = LinuxTerminalHelper::openTerminalHere(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
}


void LinuxOpenInTerminalMainWindow::on_open_desktop_clicked()
{
    bool ok = LinuxTerminalHelper::openTerminalHere(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
}


void LinuxOpenInTerminalMainWindow::on_open_tmp_clicked()
{
    bool ok = LinuxTerminalHelper::openTerminalHere(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
}


void LinuxOpenInTerminalMainWindow::on_open_self_clicked()
{
    bool ok = LinuxTerminalHelper::openTerminalHere(qApp->applicationDirPath());
}

